-
-
Notifications
You must be signed in to change notification settings - Fork 420
fix(prefer-export-from): type-import removed when using namespace import
#2771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
prefer-export-from): type-import removed when using namespace import
59b7962 to
deda324
Compare
deda324 to
4345915
Compare
| `␊ | ||
| 1 |␊ | ||
| 2 |␊ | ||
| 3 | export * as X from 'foo';␊ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this also change the behavior, it only expose type before, now it expose values. Maybe we can export type but not remove the import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, this also affects one existing test case
4345915 to
8d6b1da
Compare
| ␊ | ||
| Output:␊ | ||
| 1 |␊ | ||
| 1 | import { foo } from 'foo';␊ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't remove this (unless it's type import).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removeSpecifier can control whether the declaration should be removed if the specifier is the only one. https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/rules/fix/remove-specifier.js#L12
Currently, this code:
is autofixed to this:
which is missing the
typemodifier.This PR fixes the issue. First commit adds a test case, second commit fixes the bug